/*
 * Copyright 2010 Electronic Business Systems Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package gr.ebs.gssdroid.async;

import gr.ebs.gssdroid.http.GssHttpClient;
import gr.ebs.gssdroid.resource.RestResource;
import gr.ebs.gssdroid.util.UserDetails;
import android.os.AsyncTask;

public abstract class GssAsyncTask extends AsyncTask<String,Integer, TaskResult>{
	private UserDetails details;
	protected GssHttpClient client;
	public GssAsyncTask(UserDetails details) {
		this.details=details;
		client = new GssHttpClient(details);
	}
	
	@Override
	protected TaskResult doInBackground(String... params) {
		TaskResult result = new TaskResult();
		try {
			result.resource = doExecution(params);
		} catch (Exception e) {
			result.exception=e;
		}
		return result;
	}

	protected abstract RestResource doExecution(String[] params) throws Exception;
		
	public void publishProgressOverride(Integer... values){
		publishProgress(values);
	}

}
